Robotics 1.0 Lesson Plan
Lesson 25: Color Quest

Purpose: Learn a generic step by step process to work with any external sensor by selecting, understanding, connecting, reading, and using sensor data, using a color sensor as the example.

No. of. Classes

1 - (Time : 1:30 minutes, Each group maximum 4 children).

Materials Required

Laptop or desktop with Mu Editor installed.

CircuitPython installed on CPX board.

Circuit express board (CPX),Crickit,5v battery,USB cable.

Color sensor or any sensor of your choice

Jumper wires.

Prior knowledge

Students should know

  • How to connect external components to the CPX and Crickit
  • Run basic CircuitPython programs in Mu Editor
  • Understand that sensors provide input values to the controller.

  • Exercises

    Exercise 1:
    Select and Understand a Sensor



  • Choose any sensor. Learn how the sensor works and what type of data it gives.


    In this lesson, we will use a color sensor as the example. There will be a code in the sensor to indicate the model. You can use that code to look up documentation and code references for that sensor. In our case, the color sensor has code -> TCS230. We will look that up and learn about the sensor

    Click here to see how the color sensor works

  • Exercise 2:
    Connect the Sensor



  • Connect the selected sensor to the CPX or Crickit sensor ports using jumper wires.


    The color sensor does not work with the crickit and has to be connected to the CPX. Follow this wiring diagram for the color sensor.


  • Exercise 3:
    Read Sensor Values



  • Write a CircuitPython program to read the raw values from the sensor.


    For the color sensor, this means reading the Red, Green, and Blue values.

    Click here to see the sample code

  • Exercise 4:
    Use the Sensor Data



  • Use simple logic to understand and use the sensor values.


    For the color sensor, compare RGB values to decide whether the object is red, green, or blue. Test the program using different colored objects.

  • Solution



  • Click here to see the solution video for the working of the color sensor
  • Click here to see the full code for Exercise 4
  • Click here to see the code explanation for Exercise 4
  • Teacher's Instruction
    1. Explain that this lesson teaches a general method for working with any sensor.
    2. Introduce the color sensor as the example sensor for this process.
    3. Discuss how sensors collect real world information and send it to the CPX.
    4. Guide students to first observe how the sensor works before connecting it.
    5. Show how to connect the sensor correctly to the Crickit and CPX.
    6. Demonstrate how to read raw sensor values using CircuitPython.
    7. Help students use simple logic to turn sensor values into useful information.
    8. Encourage students to test different objects and observe how the values change.
    9. Conclude by explaining that the same steps can be used for any other sensor.
    10. Encourage children to pick a sensor they haven't used before other than color sensor and try these steps
    11. If two different objects look the same color to our eyes, will the color sensor always read the same RGB values for them? Why or why not?
    12. Can you think of some of the commonly encountered sensors around you? (Talk about sensors in cars, phones, etc)